﻿/*
ms: kb max size image
    ms=0 | ms is null => not check max size
io=1 upload image to IO (default = 1)
io=0 upload image to DB,
    cn: ConnectionString Key of Web.config to save DBImage (default = ConnectionString)
    table Image(ImageID,Content,Thumbnail,ContenType)
    
----------------
Exam:
    IO: ImageUpload/uImg.aspx?ms=60
        ImageUpload/uImg.aspx
        ImageUpload/uImg.aspx?io=1
        
    DB: ImageUpload/uImg.aspx?ms=60&io=0&cn=abcconn
        ImageUpload/uImg.aspx?io=0&cn=abcconn
        ImageUpload/uImg.aspx?io=0
*/
FCKCommands.RegisterCommand(
    'ImageUpload', 
    new FCKDialogCommand( 
        'ImageUpload', 
        'Upload tệp ảnh (tối đa 60 KB)', 
        FCKConfig.PluginsPath + 'ImageUpload/uImg.aspx?ms=60&io=1', 
        450, 400) 
);

var oInsertVariables = new FCKToolbarButton('ImageUpload', 'upload images');
oInsertVariables.IconPath = FCKConfig.PluginsPath + 'ImageUpload/img.gif';
FCKToolbarItems.RegisterItem( 'ImageUpload', oInsertVariables );

FCK.ContextMenu.RegisterListener({
    AddItems: function(menu, tag, tagName){
		if ( tagName == 'IMG' && !tag.getAttribute( '_fckfakelement' ) )
		{
			menu.AddSeparator() ;
			menu.AddItem( 'ImageUpload', FCKLang.ImageProperties, FCKConfig.PluginsPath + 'ImageUpload/img.gif' ) ;
		}
    }});